package com.fz.controller;

import com.fz.entity.Shopaddress;
import com.fz.mapper.ShopaddressMapper;
import com.fz.util.Dbutil;
import org.apache.ibatis.session.SqlSession;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.UUID;

/**
 * Created by webrx on 2017/7/2.
 */
@Controller
public class ShopingList {

    @RequestMapping(value = "/shoping.list")
    public String list(HttpServletRequest req, HttpServletResponse resp) throws IOException {
        resp.setCharacterEncoding("utf-8");
        resp.setContentType("text/html;charset=utf-8");
        //ModelAndView mv = new ModelAndView("hopinglist");
        ModelAndView mv = new ModelAndView("shop/hopinglist");
        Dbutil db02 = new Dbutil();
        SqlSession ss =db02.getSession();
        ShopaddressMapper address= ss.getMapper(ShopaddressMapper.class);

        String addressid=req.getParameter("check");
       int id=Integer.parseInt(addressid);

       Shopaddress shopaddress = address.queryById(id);
        String uuid= UUID.randomUUID().toString();
        String allprice=req.getParameter("allprice");

        HttpSession session=req.getSession();
       // String admin =session.getAttribute("admin").toString();
       mv.addObject("address",shopaddress);
        mv.addObject("uuid",uuid);
        mv.addObject("allprice",allprice);
        mv.addObject("name","是哪里");
        req.setAttribute("name","哈佛");
        req.setAttribute("address",shopaddress);
        req.setAttribute("allprice",allprice);
        req.setAttribute("uuid",uuid);




        return "forward:shop/hopinglist.jsp";
    }
}
